# calculations.py
"""Do analyitic calculations on cochlear implant data"""

def main():
    """this method is your main squeeze"""

def mean(numlist):
    """This method takes the mean of a list of numbers"""
    try :
        total = sum(numlist)
        length = len(numlist)
    except ValueError :
        print "The number list was not a list of numbers."
    except :
        print "There was a problem evaluating the number list."
    return total/length

class TestClass:
    from nose.tools import raises
    def test_mean(self):
        """This test queries the basics of the mean class"""
        assert(mean([0,0,0,0])==0)
        assert(mean([0,200])==100)
        assert(mean([0,-200]) == -100)
        assert(mean([0]) == 0)
    
    def test_floating(self):
        """This test queries the float behavior of the mean class"""
        assert(mean([1,2])==1.5)

    @raises(TypeError, ValueError)
    def test_raises_type_error():
        """This tests whether an exception is thrown for for nonnumerical input"""
        mean([1,2,3,'b'])

    @raises(Exception)
    def test_that_fails_by_passing():
        """This tests whether an exception is thrown for otherwise bad input"""
        mean("bob")

if __name__=='__main__':
    sys.exit(main())


